<?php

class Cargo{
	
	public $bd;
	public $resultado;

	
	public function __construct(){
		
		$this->bd = new Basedatos();
		
	}
		public function mostrar_cargo(){
		
		$query = "CALL ConsultarTodosCargo()";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
		public function mostrar_cargo_uno($id){
		
		$query = "CALL ConsultarUnCargo('".$id."')";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
	public function mostrar_cargo_id($id){
		
		$query = "CALL ConsultarUnCargoId('".$id."')";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
		public function editar_cargo($idcod, $nombre, $descripcion){
		
		$query = "CALL ModificarCargo('".$idcod."','".$nombre."','".$descripcion."')";
		$this->result = $this->bd->update($query);	
		
	}
		public function insertar_cargo(){
		
		$query = "CALL IngresarCargo('".$_POST["nombre"]."', '".$_POST["descr"]."')";
		$res = mysql_query($query);
		
	}
		public function existe_cargo(){
			$query = "CALL ExisteCargo(id_cargo,".$existe.")";
			$this->result = $this->bd->select($query);
			return $existe;
		}
		public function eliminar_cargo($id){
			$query = "CALL EliminarCargo(".$id.")";
			$this->result = $this->bd->delete($query);
		}
		
			public function relacion_us_cargo($id){
			$query = "CALL RelUsuarioCargo($id)";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
}
?>